﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chinook.Core
{
   public class Profiler
   {
       #region Properties
       public string ClassName { get; set; }
       public string MethodName { get; set; }
       public string Message { get; set; }
       public string StackTrace { get; set; }
       public Double ExecutionTime { get; set; }
       public long ProfileTimeStamp { get; set; }
       public DateTime ExecutionDateAndTime
       {
           get
           {
               return ConvertFromUnixTimestamp(this.ProfileTimeStamp);
           }
       }
       #endregion
     
        #region DateTime

        static DateTime ConvertFromUnixTimestamp(long unixTimeStamp)
        {
           return (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local)).AddSeconds(unixTimeStamp);
        }

        static double ConvertToUnixTimestamp(DateTime date)
        {
            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            TimeSpan diff = date - origin;
            return Math.Floor(diff.TotalSeconds);
        }
        #endregion DateTime
    }
}
